//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CCommandRegistry {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CCommandRegistry(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CCommandRegistry obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CCommandRegistry(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public static CCommandRegistry getInstance() {
    return new CCommandRegistry(nelmiscJNI.CCommandRegistry_getInstance(), false);
  }

  public void registerNamedCommandHandler(ICommandsHandler handler, String className) {
    nelmiscJNI.CCommandRegistry_registerNamedCommandHandler(swigCPtr, this, ICommandsHandler.getCPtr(handler), handler, className);
  }

  public void unregisterNamedCommandHandler(ICommandsHandler handler, String className) {
    nelmiscJNI.CCommandRegistry_unregisterNamedCommandHandler(swigCPtr, this, ICommandsHandler.getCPtr(handler), handler, className);
  }

  public boolean execute(String commandWithArgs, CLog log, boolean quiet, boolean human) {
    return nelmiscJNI.CCommandRegistry_execute__SWIG_0(swigCPtr, this, commandWithArgs, CLog.getCPtr(log), log, quiet, human);
  }

  public boolean execute(String commandWithArgs, CLog log, boolean quiet) {
    return nelmiscJNI.CCommandRegistry_execute__SWIG_1(swigCPtr, this, commandWithArgs, CLog.getCPtr(log), log, quiet);
  }

  public boolean execute(String commandWithArgs, CLog log) {
    return nelmiscJNI.CCommandRegistry_execute__SWIG_2(swigCPtr, this, commandWithArgs, CLog.getCPtr(log), log);
  }

  public void expand(SWIGTYPE_p_std__string commandName, CLog log) {
    nelmiscJNI.CCommandRegistry_expand__SWIG_0(swigCPtr, this, SWIGTYPE_p_std__string.getCPtr(commandName), CLog.getCPtr(log), log);
  }

  public void expand(SWIGTYPE_p_std__string commandName) {
    nelmiscJNI.CCommandRegistry_expand__SWIG_1(swigCPtr, this, SWIGTYPE_p_std__string.getCPtr(commandName));
  }

  public void serialCommands(IStream f) {
    nelmiscJNI.CCommandRegistry_serialCommands(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public boolean exists(String commandName) {
    return nelmiscJNI.CCommandRegistry_exists(swigCPtr, this, commandName);
  }

  public boolean isNamedCommandHandler(String handlerName) {
    return nelmiscJNI.CCommandRegistry_isNamedCommandHandler(swigCPtr, this, handlerName);
  }

  public boolean isCommand(String str) {
    return nelmiscJNI.CCommandRegistry_isCommand(swigCPtr, this, str);
  }

  public ICommand getCommand(String commandName) {
    long cPtr = nelmiscJNI.CCommandRegistry_getCommand(swigCPtr, this, commandName);
    return (cPtr == 0) ? null : new ICommand(cPtr, false);
  }

  public void enableControlCharForCommand(String commandName, boolean state) {
    nelmiscJNI.CCommandRegistry_enableControlCharForCommand(swigCPtr, this, commandName, state);
  }

  public boolean isControlCharForCommandEnabled(String commandName) {
    return nelmiscJNI.CCommandRegistry_isControlCharForCommandEnabled(swigCPtr, this, commandName);
  }

  public void initVariables(CConfigFile configFile) {
    nelmiscJNI.CCommandRegistry_initVariables(swigCPtr, this, CConfigFile.getCPtr(configFile), configFile);
  }

}
